#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

const int N = 1010, M = 10010;

//queue<int> q;

int h[N], e[M], ne[M], idx;

int cnt[N];

bool st[N];
int q[N];

int n, m, k;

void dfs(int w)
{
	st[w] = true;
	cnt[w] ++ ;
	for (int i = h[w]; ~i; i = ne[i])
	{
		int j = e[i];
		if (!st[j]) dfs(j);
	}
}

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

int main()
{
	cin >> k >> n >> m;
	
	for (int i = 0; i < k; i ++ )
	{
		cin >> q[i];
	}
	
	memset(h, -1, sizeof h);
	
	for (int i = 0; i < m; i ++ )
	{
		int a, b;
		cin >> a >> b;
		
		add(a, b);
	}
	
//	bfs();
	
	int res = 0;
	
	for (int i = 0; i < k; i ++ ) 
	{
		memset(st, 0, sizeof st);
		dfs(q[i]);
	}
	
	for (int i = 1; i <= n; i ++ ) if (cnt[i] == k) res ++ ;
	
	cout << res << endl;
	
	return 0;
}